package com.guoqing.utils;

import io.swagger.annotations.ApiOperation;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @author guoQ.z
 * @date 2021/3/17 22:09
 * TODO
 */
public class SwaggerConfigUtil {
    String groupName;

    public SwaggerConfigUtil(String groupName) {
        this.groupName = groupName;
    }

    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName(groupName)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Swagger2 title")
                .description("Swagger2 的 备注。。。")
                .version("v.1.0")
                .build();
    }
}
